package com.relax.controller;

import com.relax.order.dto.Order;
import com.relax.order.feign.OrderFeign;
import com.relax.pay.dto.PayOrder;
import com.relax.service.OrderPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/serviceApi")
public class OrderPayController {

//    @Autowired
//    private OrderPayService orderPayService;

    public OrderPayController(){
        System.out.println("OrderPayController 的构造方法");
    }

    public void setOrderFeign(OrderFeign orderFeign) {
        this.orderFeign = orderFeign;
    }

    @Autowired
    private OrderFeign orderFeign;

    @GetMapping("/order")
    public PayOrder orderPay(Integer userId) {
        Order order = orderFeign.create(userId);
        PayOrder payOrder = new PayOrder();
        payOrder.setOrderNo(order.getOrderNo());
        return payOrder;
    }

}
